class NumberFormat
{
	public inline static var DEFAULT_NUM_DECIMALS: Int = 2;

	public var numDecimals: Int; // = DEFAULT_NUM_DECIMALS;
	public var isFixedNumDecimalsForced:Bool; // = false;
	public var isDecimalSeparatorComma:Bool; // = false;
	public var isThousandSeparatorDisabled:Bool; // = false;
	
	public function new( numDecimals: Int, isFixedNumDecimalsForced:Bool, isDecimalSeparatorComma:Bool, isThousandSeparatorDisabled:Bool )
	{
		numDecimals = DEFAULT_NUM_DECIMALS;
		isFixedNumDecimalsForced  = false;
		isDecimalSeparatorComma = false;
		isThousandSeparatorDisabled = false;

		//this.numDecimals = Parser.getNumberValue (numDecimals, DEFAULT_NUM_DECIMALS, true, false);
		this.isFixedNumDecimalsForced = Parser.getBoolValue(isFixedNumDecimalsForced,false);
		this.isDecimalSeparatorComma = Parser.getBoolValue(isDecimalSeparatorComma,false);
		this.isThousandSeparatorDisabled = Parser.getBoolValue(isThousandSeparatorDisabled,false);
	}
	
	
	//singleton
//	public static function getInstance (lv,c: Float): NumberFormat{
//		if (c==2){
//			return NumberFormat.getInstanceY2(lv);
//		} else {
//			return NumberFormat.getInstance(lv);
//		}
//	}

		static var _instance: NumberFormat = null;
	
	public static function getInstance( json:Dynamic ): NumberFormat {
		if (_instance == null) {
	//				if (lv == null ||  lv == null){
	//					lv=_root.lv;
	//				}

			var o:Dynamic = {
				num_decimals: 2,
				is_fixed_num_decimals_forced: 0,
				is_decimal_separator_comma: 0,
				is_thousand_separator_disabled: 0
			};
			
			ObjectHelper.merge_2( json, o );
			
			_instance = new NumberFormat (
				o.num_decimals,
				o.is_fixed_num_decimals_forced==1,
				o.is_decimal_separator_comma==1,
				o.is_thousand_separator_disabled==1
				);
//			 trace ("getInstance NEW!!!!");
//			 trace (_instance.numDecimals);
//			 trace (_instance.isFixedNumDecimalsForced);
//			 trace (_instance.isDecimalSeparatorComma);
//			 trace (_instance.isThousandSeparatorDisabled);
		} else {
				//trace ("getInstance found");
		}
		return _instance;
	}

		static var _instanceY2: NumberFormat = null;
	
	public static function getInstanceY2( json:Dynamic ): NumberFormat{
		if (_instanceY2 == null) {
	//				if (lv == null ||  lv == null){
	//					lv=_root.lv;
	//				}
			
			var o:Dynamic = {
				num_decimals: 2,
				is_fixed_num_decimals_forced: 0,
				is_decimal_separator_comma: 0,
				is_thousand_separator_disabled: 0
			};
			
			ObjectHelper.merge_2( json, o );
			
			_instanceY2 = new NumberFormat (
				o.num_decimals,
				o.is_fixed_num_decimals_forced==1,
				o.is_decimal_separator_comma==1,
				o.is_thousand_separator_disabled==1
				);
			
				//trace ("getInstanceY2 NEW!!!!");
		} else {
				//trace ("getInstanceY2 found");
		}
		return _instanceY2;
	}
}
